---
layout: "default"
description: "Swift documentation for 'unsafeBitCast'"
keywords: ""
title: "unsafeBitCast"
root: "/v5.1"
---

<div class="intro-declaration"><code class="language-swift">func unsafeBitCast(_:to:)(_ x: T, to type: U.Type) -> U</code></div><div class="discussion comment"><p>Returns the bits of the given instance, interpreted as having the specified
type.
</p>
<p>Use this function only to convert the instance passed as <code>x</code> to a
layout-compatible type when conversion through other means is not
possible. Common conversions supported by the Swift standard library
include the following:</p>
<blockquote>
<p>Warning:
Calling this function breaks the guarantees of the Swift type system; use with extreme care.</p>
</blockquote>
</div>